package com.zjc.yohoshop.mvp.view.adapter;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.makeramen.roundedimageview.RoundedImageView;
import com.zjc.yohoshop.R;
import com.zjc.yohoshop.bean.SeeListEntity;
import com.zjc.yohoshop.network.API;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SeeListAdapter extends BaseQuickAdapter<SeeListEntity.ValuesBean, BaseViewHolder> {

    public SeeListAdapter(int layoutResId ) {
        super(layoutResId);
    }


    @Override
    protected void convert(BaseViewHolder helper, SeeListEntity.ValuesBean item) {
        ImageView edt_icon = helper.getView(R.id.riv_item_see_list_edt_icon);
        RoundedImageView news_img
                = helper.getView(R.id.iv_item_see_list_news_img);
        Glide.with(helper.itemView.getContext()).load(API.BaseUrl + item.see_edt_icon).into(edt_icon);
        Glide.with(helper.itemView.getContext()).load(API.BaseUrl + item.see_news_img).into(news_img);

        helper.setText(R.id.tv_item_see_list_edt_name, item.see_edt_name);
        helper.setText(R.id.tv_item_see_list_news_title, item.see_news_title);
        helper.setText(R.id.tv_item_see_list_edt_tag, item.see_edt_tag);
        helper.setText(R.id.tv_item_see_list_news_collection, item.see_news_collection);

        Date date = new Date(Long.parseLong(item.see_news_time));
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM月dd日 kk:mm");
        String time = simpleDateFormat.format(date);
        helper.setText(R.id.tv_item_see_list_news_time, time);

        RecyclerView rv_item_see_list_brand = helper.getView(R.id.rv_item_see_list_brand);
        SeeListBrandAdapter seeListBrandAdapter = new SeeListBrandAdapter(R.layout.item_see_list_brand);
        seeListBrandAdapter.addData(item.banner);
        rv_item_see_list_brand.setLayoutManager(new LinearLayoutManager(helper.itemView.getContext(), LinearLayoutManager.HORIZONTAL, false));
        rv_item_see_list_brand.setAdapter(seeListBrandAdapter);

    }
}
